package com.github.live.util;

import com.github.livebase.bean.Channel;
import com.github.livebase.bean.ChannelGroup;
import com.github.livebase.util.template.CompositeMap;
import com.github.livebase.util.template.Template;

import java.util.Map;

/**
 * @ClassName SourceWrapper
 * @description: Source的包装类，仅附加信息可修改
 * @author: biao532
 * @create: 2023-12-28 15:19
 * @Version 1.0
 **/
public class SourceWrapper extends Channel.Source {
    public SourceWrapper(Map<String, String> all, ChannelGroup group, Channel channel, Channel.Source source) {
        super();
        CompositeMap<String, String> map = new CompositeMap<>();
        map.addMap(all, group.getOpt(), channel.getOpt(), source.getOpt());
        super.setOpt(map);
        super.setLive(source.getLive());
        super.setName(source.getName());
        super.setReplay(source.getReplay());
        super.setResolution(source.getResolution());
    }

    @Override
    public void setResolution(int resolution) {

    }

    @Override
    public void setName(String name) {

    }

    @Override
    public String getLive() {
        return Template.template.parseExpression(super.getLive())
                .eval(getOpt()).toString();
    }

    @Override
    public void setLive(String live) {

    }

    @Override
    public boolean supportedReplay() {
        return super.supportedReplay();
    }

    @Override
    public String getReplay() {
        return Template.template.parseExpression(super.getReplay())
                .eval(getOpt()).toString();
    }

    @Override
    public void setReplay(String replay) {

    }
}
